package loads

import (
	"JVM/Jvmgo/GoToJVM/instructions/base"
	"JVM/Jvmgo/GoToJVM/runtimeData"
)

/*
	这里写的是lload系列命令，
	即将long类型数据从本地变量推送到操作数栈顶的字节码命令
*/

type LLOAD struct {
	base.Index8Instruction
}
type LLOAD_0 struct {
	base.NoOperandsInstruction
}
type LLOAD_1 struct {
	base.NoOperandsInstruction
}
type LLOAD_2 struct {
	base.NoOperandsInstruction
}
type LLOAD_3 struct {
	base.NoOperandsInstruction
}

func _lload(frame *runtimeData.Frame, index uint) {
	val := frame.LocalVars().GetLong(index)
	frame.OperandStack().PushLong(val)
}

func (self LLOAD) Execute(frame *runtimeData.Frame) {
	_aload(frame, uint(self.Index))
}
func (self LLOAD_0) Execute(frame *runtimeData.Frame) {
	_lload(frame, 0)
}
func (self LLOAD_1) Execute(frame *runtimeData.Frame) {
	_lload(frame, 1)
}
func (self LLOAD_2) Execute(frame *runtimeData.Frame) {
	_lload(frame, 2)
}
func (self LLOAD_3) Execute(frame *runtimeData.Frame) {
	_lload(frame, 3)
}
